/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI.NVQL;

import POJO.NhanVien;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.DefaultTableModel;
import DAO.NhanVienDao;
import javax.swing.JOptionPane;

/**
 *
 * @author Khoi
 */
public class frQuanLyNhanVien extends javax.swing.JInternalFrame {

	/**
	 * Creates new form frQuanLyNhanVien
	 */
	private DefaultTableModel tbmodel;
	private DefaultTableModel tbmodelShow;

	public frQuanLyNhanVien() {
		initComponents();
		load();
		if (tbDSNV.getRowCount() > 0) {
			hienThiTextBox(0);
		}

	}

	private void DefaultFrom() {
		tbmodel = new DefaultTableModel();
		tbmodelShow = new DefaultTableModel();



		this.tbmodel.addColumn("c1");
		this.tbmodel.addColumn("c2");
		this.tbmodel.addColumn("c3");
		this.tbmodel.addColumn("c4");
		this.tbmodel.addColumn("c5");
		this.tbmodel.addColumn("c6");

		this.tbmodelShow.addColumn("STT");
		this.tbmodelShow.addColumn("Mã nhân viên");
		this.tbmodelShow.addColumn("Tên nhân viên ");
		this.tbmodelShow.addColumn("Username");
		this.tbmodelShow.addColumn("Loại nhân viên");

	//	tbDSNV.setModel(tbmodelShow);


	}

	private void load() {

		ArrayList<NhanVien> ds = new ArrayList<NhanVien>();
		try {
			ds = NhanVienDao.layDanhSach();

		} catch (Exception ex) {
			Logger.getLogger(frQuanLyNhanVien.class.getName()).log(Level.SEVERE, null, ex);
		}

		DefaultFrom();
		int i = 1;
		String[] lnv = {"Nhân viên kho", "Nhân viên bán hàng", "Nhân viên giao hàng", "Nhân viên quản lý"};
		for (NhanVien nv : ds) {
			Object[] items = new Object[]{
				nv.getMaNV(),
				nv.getTenNV(),
				nv.getUserName(),
				nv.getPassWord(),
				nv.getLoaiNV(),
				nv.getTrangThai()
			};
			tbmodel.addRow(items);

			Object[] items2 = new Object[]{i,
				nv.getMaNV(),
				nv.getTenNV(),
				nv.getUserName(),
				lnv[nv.getLoaiNV() - 1]
			};
			tbmodelShow.addRow(items2);
			i++;
		}

		tbDSNV.setModel(tbmodelShow);
		// canh deu cac dong
		int[] va = {10, 10, 30, 20, 30};
		int[] pt = new int[5];
		for (int l = 0; l < 5; l++) {
			pt[l] = tbDSNV.getWidth() * va[l] / 100;
			tbDSNV.getColumnModel().getColumn(l).setPreferredWidth(pt[l]);

		}
		defaultNut();
	}

	/**
	 * This method is called from within the constructor to initialize the
	 * form. WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
       // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
       private void initComponents() {

              jPanel4 = new javax.swing.JPanel();
              jLabel5 = new javax.swing.JLabel();
              jPanel1 = new javax.swing.JPanel();
              txMaNV = new javax.swing.JTextField();
              txTenNV = new javax.swing.JTextField();
              jLabel1 = new javax.swing.JLabel();
              jLabel2 = new javax.swing.JLabel();
              jLabel3 = new javax.swing.JLabel();
              jLabel4 = new javax.swing.JLabel();
              cbLoaiNV = new javax.swing.JComboBox();
              ckDaKhoa = new javax.swing.JCheckBox();
              jLabel6 = new javax.swing.JLabel();
              txUsername = new javax.swing.JTextField();
              jLabel7 = new javax.swing.JLabel();
              txPassword = new javax.swing.JPasswordField();
              jPanel2 = new javax.swing.JPanel();
              btMoi = new javax.swing.JButton();
              btThem = new javax.swing.JButton();
              btXoa = new javax.swing.JButton();
              btSua = new javax.swing.JButton();
              btHienThi = new javax.swing.JButton();
              jPanel3 = new javax.swing.JPanel();
              jScrollPane1 = new javax.swing.JScrollPane();
              tbDSNV = new javax.swing.JTable();

              setClosable(true);
              setIconifiable(true);
              setMaximizable(true);
              setResizable(true);

              jLabel5.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
              jLabel5.setText("QUẢN LÝ NHÂN VIÊN");

              javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
              jPanel4.setLayout(jPanel4Layout);
              jPanel4Layout.setHorizontalGroup(
                     jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel5)
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
              );
              jPanel4Layout.setVerticalGroup(
                     jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel5)
                            .addContainerGap())
              );

              txMaNV.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            txMaNVActionPerformed(evt);
                     }
              });

              jLabel1.setText("Mã nhân viên:");

              jLabel2.setText("Tên nhân viên:");

              jLabel3.setText("Loại nhân viên:");

              jLabel4.setText("Trang thái:");

              cbLoaiNV.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Nhân viên kho", "Nhân viên bán hàng", "Nhân viên giao hàng", "Nhân viên quản lý" }));

              ckDaKhoa.setText("Đã khóa");

              jLabel6.setText("Username:");

              jLabel7.setText("Password:");

              txPassword.setText("jPasswordField1");

              javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
              jPanel1.setLayout(jPanel1Layout);
              jPanel1Layout.setHorizontalGroup(
                     jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGap(108, 108, 108)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                   .addComponent(jLabel4)
                                   .addComponent(jLabel1)
                                   .addComponent(jLabel2)
                                   .addComponent(jLabel3)
                                   .addComponent(jLabel6)
                                   .addComponent(jLabel7))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                   .addComponent(txMaNV)
                                   .addComponent(txTenNV)
                                   .addComponent(cbLoaiNV, 0, 200, Short.MAX_VALUE)
                                   .addComponent(txUsername, javax.swing.GroupLayout.Alignment.TRAILING)
                                   .addComponent(ckDaKhoa)
                                   .addComponent(txPassword))
                            .addContainerGap(283, Short.MAX_VALUE))
              );
              jPanel1Layout.setVerticalGroup(
                     jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGap(0, 0, 0)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                   .addComponent(txMaNV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                   .addComponent(jLabel1))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                   .addComponent(txTenNV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                   .addComponent(jLabel2))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                   .addComponent(txUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                   .addComponent(jLabel6))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                   .addComponent(jLabel7)
                                   .addComponent(txPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                   .addComponent(jLabel3)
                                   .addComponent(cbLoaiNV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 6, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                   .addComponent(jLabel4)
                                   .addComponent(ckDaKhoa))
                            .addGap(0, 0, 0))
              );

              btMoi.setText("Mới");
              btMoi.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            btMoiActionPerformed(evt);
                     }
              });

              btThem.setText("Thêm");
              btThem.setEnabled(false);
              btThem.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            btThemActionPerformed(evt);
                     }
              });

              btXoa.setText("Xóa");
              btXoa.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            btXoaActionPerformed(evt);
                     }
              });

              btSua.setText("Sửa");
              btSua.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            btSuaActionPerformed(evt);
                     }
              });

              btHienThi.setText("Hiển thị");
              btHienThi.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            btHienThiActionPerformed(evt);
                     }
              });

              javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
              jPanel2.setLayout(jPanel2Layout);
              jPanel2Layout.setHorizontalGroup(
                     jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel2Layout.createSequentialGroup()
                            .addGap(140, 140, 140)
                            .addComponent(btMoi)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btThem)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btXoa)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btSua)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btHienThi)
                            .addContainerGap(231, Short.MAX_VALUE))
              );
              jPanel2Layout.setVerticalGroup(
                     jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel2Layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                   .addComponent(btMoi)
                                   .addComponent(btThem)
                                   .addComponent(btXoa)
                                   .addComponent(btSua)
                                   .addComponent(btHienThi))
                            .addGap(0, 0, Short.MAX_VALUE))
              );

              jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Danh sách nhân viên"));

              tbDSNV.setModel(new javax.swing.table.DefaultTableModel(
                     new Object [][] {

                     },
                     new String [] {
                            "STT", "Mã nhân viên", "Tên nhân viên", "Username", "Loại nhân viên"
                     }
              ));
              tbDSNV.addMouseListener(new java.awt.event.MouseAdapter() {
                     public void mouseClicked(java.awt.event.MouseEvent evt) {
                            tbDSNVMouseClicked(evt);
                     }
              });
              jScrollPane1.setViewportView(tbDSNV);

              javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
              jPanel3.setLayout(jPanel3Layout);
              jPanel3Layout.setHorizontalGroup(
                     jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addComponent(jScrollPane1)
              );
              jPanel3Layout.setVerticalGroup(
                     jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 209, Short.MAX_VALUE)
              );

              javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
              getContentPane().setLayout(layout);
              layout.setHorizontalGroup(
                     layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(layout.createSequentialGroup()
                            .addGap(0, 0, 0)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                   .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                   .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                   .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                   .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGap(0, 0, 0))
              );
              layout.setVerticalGroup(
                     layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(layout.createSequentialGroup()
                            .addGap(0, 0, 0)
                            .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, 0)
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, 0)
                            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, 0)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGap(0, 0, 0))
              );

              pack();
       }// </editor-fold>//GEN-END:initComponents

	private void defaultNut() {
		btMoi.setEnabled(true);
		btThem.setEnabled(false);
		btSua.setEnabled(true);
		btXoa.setEnabled(true);
		btHienThi.setEnabled(true);
	}
       private void btMoiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btMoiActionPerformed
		// TODO add your handling code here:
		xoaTextBox();

		txMaNV.setEnabled(false);
		btMoi.setEnabled(false);
		btThem.setEnabled(true);
		btSua.setEnabled(false);
		btXoa.setEnabled(false);
		btHienThi.setEnabled(true);
		txTenNV.requestFocusInWindow();//dat focust tai txTen
       }//GEN-LAST:event_btMoiActionPerformed
	private boolean kiemTraTruocKhiThem() {
		if (txTenNV.getText().trim().length() == 0) {
			return true;
		}
		if (txUsername.getText().trim().length() == 0) {
			return true;
		}

		if (txPassword.getText().trim().length() == 0) {
			return true;
		}
		return false;
	}
       private void btThemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btThemActionPerformed
		// TODO add your handling code here:
		if (kiemTraTruocKhiThem()) {
			JOptionPane.showMessageDialog(this, "Nhập đầy đủ thông tin rồi mới thêm.", "Thông báo lỗi", JOptionPane.ERROR_MESSAGE);
			txTenNV.requestFocusInWindow();
			return;
		}

		NhanVien nv = new NhanVien();
		NhanVien nvtt = new NhanVien();

		nv.setMaNV(0);

		nv.setTenNV(txTenNV.getText().trim());
		nv.setUserName(txUsername.getText().trim());
		nv.setPassWord(txPassword.getText().trim());
		nv.setLoaiNV(cbLoaiNV.getSelectedIndex() + 1);
		nv.setTrangThai((ckDaKhoa.isSelected() == true) ? 0 : 1);

		nvtt.setUserName(txUsername.getText().trim());
		NhanVienDao dao = new NhanVienDao();
		try {
			nvtt = dao.getByUsername(nv.getUserName());
		} catch (Exception e) {
		}
		if (nvtt != null) {
			JOptionPane.showMessageDialog(this, "Không thể sử dụng username này.", "Thông báo lỗi", JOptionPane.ERROR_MESSAGE);
			nvtt.setMaNV(0);
			return;

		}
		boolean kq = false;
		try {
			kq = dao.them(nv);
			if (kq) {
				JOptionPane.showMessageDialog(this, "Thêm thành công ");
			} else {
				JOptionPane.showMessageDialog(this, "Không thể thêm   ");

			}
		} catch (Exception e) {
		}
		if (kq) {
			load();
		}

       }//GEN-LAST:event_btThemActionPerformed

       private void btXoaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btXoaActionPerformed
		// TODO add your handling code here:

		if (txMaNV.getText().length() == 0) {
			JOptionPane.showMessageDialog(this, "Chọn người dùng rồi mới xóa.", "Thông báo lỗi", JOptionPane.ERROR_MESSAGE);
			return;

		}
		NhanVien nv = new NhanVien();

		nv.setMaNV(Integer.valueOf(txMaNV.getText()));
		NhanVienDao dao = new NhanVienDao();
		boolean kq = false;
		try {
			kq = dao.xoa(nv.getMaNV());
			if (kq) {
				JOptionPane.showMessageDialog(this, "Xóa thành công ");
			} else {
				JOptionPane.showMessageDialog(this, "Không thể xóa   ");

			}
		} catch (Exception e) {
		}
		if (kq) {
			load();
		}
		if (tbmodel.getRowCount() > 0) {
			hienThiTextBox(0);
		} else {
			xoaTextBox();
		}

       }//GEN-LAST:event_btXoaActionPerformed

       private void btHienThiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btHienThiActionPerformed
		// TODO add your handling code here:
		defaultNut();
		load();
		if (tbDSNV.getRowCount() > 0) {
			hienThiTextBox(0);
		} else {
			xoaTextBox();
		}
       }//GEN-LAST:event_btHienThiActionPerformed

	private void xoaTextBox() {
		txMaNV.setText("");
		txTenNV.setText("");
		txUsername.setText("");
		txPassword.setText("");
		ckDaKhoa.setSelected(true);

	}

	private void hienThiTextBox(int dong) {
		Object obma = tbmodel.getValueAt(dong, 0);
		Object obten = tbmodel.getValueAt(dong, 1);
		Object obus = tbmodel.getValueAt(dong, 2);
		Object obpa = tbmodel.getValueAt(dong, 3);
		Object loai = tbmodel.getValueAt(dong, 4);
		Object trang = tbmodel.getValueAt(dong, 5);
		int t = (Integer) trang;
		boolean b;
		if (t == 1) {
			b = false;
		} else {
			b = true;
		}


		txMaNV.setText(obma.toString());
		txTenNV.setText(obten.toString());
		txUsername.setText(obus.toString());
		txPassword.setText(obpa.toString());
		int tt = (Integer) loai;
		tt -= 1;
		cbLoaiNV.setSelectedIndex(tt);
		ckDaKhoa.setSelected(b);
	}

       private void tbDSNVMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbDSNVMouseClicked
		// TODO add your handling code here:
		int dong = tbDSNV.getSelectedRow();

		if (dong > tbDSNV.getRowCount() || dong == -1) {
			xoaTextBox();
		} else {
			hienThiTextBox(dong);
		}
		defaultNut();
       }//GEN-LAST:event_tbDSNVMouseClicked

       private void btSuaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSuaActionPerformed
		// TODO add your handling code here:
		// TODO add your handling code here:
		if (txMaNV.getText().length() == 0) {
			JOptionPane.showMessageDialog(this, "Chọn người dùng rồi mới sửa.", "Thông báo lỗi", JOptionPane.ERROR_MESSAGE);
			return;

		}
		NhanVien nv = new NhanVien();

		nv.setMaNV(Integer.valueOf(txMaNV.getText()));
		nv.setTenNV(txTenNV.getText().trim());
		nv.setUserName(txUsername.getText().trim());
		nv.setPassWord(txPassword.getText().trim());
		nv.setLoaiNV(cbLoaiNV.getSelectedIndex() + 1);


		nv.setTrangThai((ckDaKhoa.isSelected() == true) ? 0 : 1);

		NhanVienDao dao = new NhanVienDao();
		boolean kq = false;
		try {
			kq = dao.capNhat(nv);
			if (kq) {
				JOptionPane.showMessageDialog(this, "Sửa thành công ");
			} else {
				JOptionPane.showMessageDialog(this, "Không thể sửa   ");

			}
		} catch (Exception e) {
		}
		if (kq) {
			load();
		}
		if (tbmodel.getRowCount() > 0) {
			hienThiTextBox(0);
		} else {
			xoaTextBox();
		}
       }//GEN-LAST:event_btSuaActionPerformed

       private void txMaNVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txMaNVActionPerformed
              // TODO add your handling code here:
       }//GEN-LAST:event_txMaNVActionPerformed

       // Variables declaration - do not modify//GEN-BEGIN:variables
       private javax.swing.JButton btHienThi;
       private javax.swing.JButton btMoi;
       private javax.swing.JButton btSua;
       private javax.swing.JButton btThem;
       private javax.swing.JButton btXoa;
       private javax.swing.JComboBox cbLoaiNV;
       private javax.swing.JCheckBox ckDaKhoa;
       private javax.swing.JLabel jLabel1;
       private javax.swing.JLabel jLabel2;
       private javax.swing.JLabel jLabel3;
       private javax.swing.JLabel jLabel4;
       private javax.swing.JLabel jLabel5;
       private javax.swing.JLabel jLabel6;
       private javax.swing.JLabel jLabel7;
       private javax.swing.JPanel jPanel1;
       private javax.swing.JPanel jPanel2;
       private javax.swing.JPanel jPanel3;
       private javax.swing.JPanel jPanel4;
       private javax.swing.JScrollPane jScrollPane1;
       private javax.swing.JTable tbDSNV;
       private javax.swing.JTextField txMaNV;
       private javax.swing.JPasswordField txPassword;
       private javax.swing.JTextField txTenNV;
       private javax.swing.JTextField txUsername;
       // End of variables declaration//GEN-END:variables
}
